
var app = getApp();
var ApiUrl = app.globalData.ApiUrl;
var mph = require("../../utils/util.js");
Page({
  data: {
    winHeight: "",//窗口高度
    currentTab: 0, //预设当前项的值
    scrollLeft: 0, //tab标题的滚动条位置
    get_order_info:[],
    expertList: [
      { //假数据
        id: 1,
        u_name: 'shengqing',
        text: '申请售后',
      },
      // { //假数据
      //   id: 2,
      //   u_name: 'quanbushouhou',
      //   text: '全部售后',
      // }
    ]
  },
  go_order_detail() {
    wx.navigateTo({
      url: '/pages/order_detail/order_detail'
    })
  },
  go_after_sales_type(e) {//跳转售后类型
    console.log(e.currentTarget.dataset.rec_id);
    let rec_id = e.currentTarget.dataset.rec_id;
    let order_id = this.data.get_order_info.order_id;
    wx.navigateTo({
      url: '/pages/after_sales_type/after_sales_type?rec_id=' + rec_id + '&order_id=' + order_id
    })
  },
  // 滚动切换标签样式
  switchTab: function (e) {
    this.setData({
      currentTab: e.detail.current
    });
    this.checkCor();
  },
  // 点击标题切换当前页时改变样式
  swichNav: function (e) {
    var cur = e.target.dataset.current;
    if (this.data.currentTaB == cur) { return false; }
    else {
      this.setData({
        currentTab: cur
      })
    }
  },
  //判断当前滚动超过一屏时，设置tab标题滚动条。
  checkCor: function () {
    if (this.data.currentTab > 4) {
      this.setData({
        scrollLeft: 300
      })
    } else {
      this.setData({
        scrollLeft: 0
      })
    }
  },
  //index.php?act=member_order&op=order_info
  get_order_info(order_id) {
    var that = this;
    let k = wx.getStorageSync('key');
    var url = 'index.php?act=member_order&op=order_info&order_id=' + order_id;
    let list = {
      key:k
    }
    // console.log(key, order_id);
    mph.postRequest(url, list, function (res) {

      if (res.data.code == 200) {
        let resl = res.data.datas.order_info;
        
        console.log('我的dange订单列表:===>', resl);
        that.setData({
          get_order_info: resl
        })
      }
    });

  },
  onLoad: function (option) {
    let that = this;

    if (option.order_id){
      console.log(option);
      that.get_order_info(option.order_id);
    }



    //  高度自适应
    wx.getSystemInfo({
      success: function (res) {
        var clientHeight = res.windowHeight,
          clientWidth = res.windowWidth,
          rpxR = 750 / clientWidth;
        var calc = clientHeight * rpxR - 180;
//console.log(calc)
        that.setData({
          winHeight: calc
        });
      }
    });
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})